package com.SmartLED.Controller;

import com.SmartLED.Entity.admin_user;
import com.SmartLED.Service.BaseMapperService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.SmartLED.Common.Log4JUtils;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Frozen on 2017/1/5.
 */

@SpringBootApplication
@RestController
public class FirstController extends BaseController{

    @Autowired
    private BaseMapperService baseMapperService;

    @ApiOperation(value = "测试接口")
    @PostMapping("/test")
    public String test(HttpServletRequest request) throws JsonProcessingException{
        Log4JUtils.getLogger().debug("/test");
//        List<Map> mapList = firstService.query();
        ObjectMapper objectMapper = new ObjectMapper();
        Map resultMap = new HashMap();

        decode(request);

        Log4JUtils.getLogger().debug(params);


        admin_user admin_user = new  admin_user();
        admin_user.setUsername("1".toString());
        admin_user.setPassword("2".toString());
        admin_user.setId(3);
        baseMapperService.save(admin_user);

        baseMapperService.find(admin_user,null,null);

        baseMapperService.update(admin_user,new HashMap(){{put("id","3");}});


        resultMap.put("code","0");
        resultMap.put("msg","成功");
        resultMap.put("data","");
        return  objectMapper.writeValueAsString(resultMap);
    }
}
